﻿#region 命名空间

using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sharp.Domain.PlatformBoundedContext.MasterDataModule.Aggregates;
using Sharp.Domain.PlatformBoundedContext.MessageModule.Aggregates;
using Sharp.Domain.PlatformBoundedContext.UserModule.Aggregates;
using Sharp.Domain.Model;
using Sharp.Infrastructure;

#endregion

namespace Sharp.Domain.PlatformBoundedContext.ModelConfigurations
{
    public partial class MasterDataTypeConfiguration<TMasterData> : EntityTypeConfiguration<TMasterData>
        where TMasterData : class, IEntity, IMasterData
    {
        public MasterDataTypeConfiguration()
        {
            Config();
        }
        #region 通用配置
        public virtual void Config()
        {
            HasKey(c => c.Code);

            Property(c => c.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(c => c.Name)
                .IsRequired()
                .HasMaxLength(50);
            Property(c => c.Code)
                .IsRequired()
                .HasMaxLength(50);
     

            Property(c => c.FullName)
                .IsOptional()
                .HasMaxLength(255);
 
            Property(c => c.ParentCode)
                .HasMaxLength(50)
                .IsOptional();
 
 
        }

        #endregion
    }

    #region 其他主数据实现
    /// <summary>
    /// 行政区域
    /// </summary>
    public partial class AdministrativeDivisionConfiguration : MasterDataTypeConfiguration<AdministrativeDivision>
    {
        public override void Config()
        {
            base.Config();

            Property(t => t.Abbreviation)
               .HasMaxLength(50)
               .IsOptional();
        }
    }
    public partial class DegreeConfiguration : MasterDataTypeConfiguration<Degree> { }
    public partial class EducationalBackgroundConfiguration : MasterDataTypeConfiguration<EducationalBackground> { }
    public partial class GenderConfiguration : MasterDataTypeConfiguration<Gender> { }
    public partial class GradeConfiguration : MasterDataTypeConfiguration<Grade> { }
    public partial class MarriedConfiguration : MasterDataTypeConfiguration<Married> { }
    public partial class NationConfiguration : MasterDataTypeConfiguration<Nation> { }
    public partial class PostStateConfiguration : MasterDataTypeConfiguration<PostState> { }
    public partial class PosttitleConfiguration : MasterDataTypeConfiguration<Posttitle> { }


    #endregion
}